package Eyjafjalla.relic;

import Eyjafjalla.action.DrawToCloudAction;
import Eyjafjalla.helper.EyjafjallaHelper;
import Eyjafjalla.helper.StringHelper;
import basemod.abstracts.CustomRelic;
import com.megacrit.cardcrawl.actions.common.RelicAboveCreatureAction;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import com.megacrit.cardcrawl.rewards.RewardItem;

public class TreasureMap extends CustomRelic {

    public static final String ID = "eyjafjalla:TreasureMap";

    public TreasureMap(){
        super(ID, ImageMaster.loadImage(StringHelper.getRelicIMGPATH(ID,false)),ImageMaster.loadImage(StringHelper.getRelicIMGPATH(ID,true)),RelicTier.COMMON,LandingSound.SOLID);
        this.counter = 1;
    }

    @Override
    public void onChestOpenAfter(boolean bossChest) {
        if (!bossChest && this.counter > 0) {
            --this.counter;
            this.flash();
            RewardItem cardItem = new RewardItem();
            cardItem.cards.clear();
            cardItem.cards.addAll(EyjafjallaHelper.getDollyCards(false,3));
            AbstractDungeon.getCurrRoom().addCardReward(cardItem);
            if (this.counter == 0) {
                this.setCounter(-2);
            }
        }
    }

    @Override
    public void setCounter(int setCounter) {
        this.counter = setCounter;
        if (setCounter == -2) {
            this.usedUp();
            this.counter = -2;
        }
    }

    @Override
    public boolean canSpawn() {
        return AbstractDungeon.floorNum<=40||Settings.isEndless;
    }

    @Override
    public String getUpdatedDescription() {
        return DESCRIPTIONS[0];
    }

    @Override
    public AbstractRelic makeCopy() {
        return new TreasureMap();
    }
}



